There are numerous ways to retrieve (query) the organization (business) data in Dynamics CRM. This page provides a review of the various query mechanisms.
Data Retrieval within the CRM User-interface
This section lists the GUI-based ways to retrieve and view CRM organization data.
CRM Form and Views
Quick Find Multi-entity Quick Find (CRM 2015)
Advanced Find Charts
Report Wizard
SQL Server Reporting Services (SSRS) Reports
Workflow (e.g., retrieve data from a parent record during workflow execution)
Export to Excel from CRM then further filter the data in Excel
Code-based Data Retrieval
The Microsoft Dynamics CRM SDK provides an article titled "Retrieve data with queries" that provides a good overview.
SQL Server T-SQL and Filtered Views (Dynamics CRM on-premises installations only)
- SQL can also be used (indirectly) with CRM Online if data is copied to a SQL database. For example, use Scribe Online to copy data and then run SQL on the retrieved data.
In a Dynamic CRM plug-in, define a "pre image" or "post image" to instruct the execution pipeline to query for organization data and provide the resulting Entity object in the plug-in context.
Execute System and User Views using ExecuteByIdSavedQueryRequest and ExecuteByIdUserQueryRequest.
Besides the GUI-based tools that Microsoft provides (see section "Data Retrieval within the CRM User-interface" above), there are also several third-party tools that can help with data retrieval.
Data Retrieval within the CRM User-interface
This section lists the GUI-based ways to retrieve and view CRM organization data.CRM Form and Views
Quick Find
Multi-entity Quick Find (CRM 2015)
Advanced Find
Charts
Report Wizard
SQL Server Reporting Services (SSRS) Reports
Workflow (e.g., retrieve data from a parent record during workflow execution)
Export to Excel from CRM then further filter the data in Excel
Code-based Data Retrieval
The Microsoft Dynamics CRM SDK provides an article titled "Retrieve data with queries" that provides a good overview.Generate "early bound" CRM classes, then use LINQ to query CRM data.
- LINQ query Examples
- You can also use LINQ for late-bound queries.
FetchXML
- FetchExpression
OData
- JavaScript
- jQuery
SDK.REST.js (e.g., Function retrieveRecord)
Retrieve records for many-to-many relationships using intersect entities
SQL Server T-SQL and Filtered Views (Dynamics CRM on-premises installations only)
- SQL can also be used (indirectly) with CRM Online if data is copied to a SQL database. For example, use Scribe Online to copy data and then run SQL on the retrieved data.
Microsoft.Xrm.Sdk.Query Namespace
QueryExpression Class
Contains a complex query expressed in a hierarchy of expressions.QueryByAttribute Class
Contains a query that is expressed as a set of attribute and value pairs.IOrganizationService
Retrieve Method
RetrieveMultiple Method
RetrieveMultipleRequest Method
Microsoft.Crm.Sdk.Messages Namespace
There are numerous data and metadata retrieval methods in the Microsoft.Crm.Sdk.Messages SDK namespace.Other Data Retrieval Classes and Methods
In a Dynamic CRM plug-in, define a "pre image" or "post image" to instruct the execution pipeline to query for organization data and provide the resulting Entity object in the plug-in context.Execute System and User Views using ExecuteByIdSavedQueryRequest and ExecuteByIdUserQueryRequest.
OrganizationServiceContext.CreateQuery Method
Query hierarchical data
Convert a QueryExpression object to FetchXml: QueryExpressionToFetchXmlRequest
Convert a FetchXml query to a QueryExpression object: FetchXmlToQueryExpressionRespons
Query for duplicate records using BulkDetectDuplicatesRequest
Find knowledge base articles by keyword using SearchByKeywordsKbArticleRequest (also see SearchByBodyKbArticleRequest and other SearchBy* methods)
There are many methods available in the CrmServiceClient class for retrieving data in Microsoft Dynamics CRM.
GetAttributeValue method: Gets the value of an attribute (field). (SDK, Full explanation, Extended explanation)
CRM Query and Reporting Tools
Besides the GUI-based tools that Microsoft provides (see section "Data Retrieval within the CRM User-interface" above), there are also several third-party tools that can help with data retrieval.It's also possible to query CRM metadata.